from selenium import webdriver
import  time
from selenium.webdriver.common.by import By


driver=webdriver.Chrome(r'D:\bianchengerbianchenger\driver\chromedriver.exe')
driver.get('http://47.107.178.45/phpwind/')
driver.maximize_window()



def get_this_page():
    all_tr = driver.find_elements(By.TAG_NAME,'tr')
    for i in all_tr:
        plate = i.find_element(By.CSS_SELECTOR,'p.title a+a').text               #p.就是第一个p了
        title = i.find_element(By.CSS_SELECTOR,'p.title a+a+a').text
        author = i.find_element(By.CSS_SELECTOR,'p[class="info"] a').text
        publish_time = i.find_element(By.CSS_SELECTOR,'p[class="info"] span').text
        page_view = i.find_element(By.CSS_SELECTOR,'td[class="num"] span+span em').text
        reply_numbers = i.find_element(By.CSS_SELECTOR,'td[class="num"] span em').text

        print("板块: {}  主题: {}  作者:{}  发布时间{}  浏览量{}  回复量{}".format(plate,title,author,publish_time,page_view,reply_numbers))

def next_page():
    driver.find_element(By.CSS_SELECTOR,'[class="pages_next J_pages_next"]').click()


for i in range(3):
    print('---------------这是第{}页-------------------'.format(i+1))
    get_this_page()
    time.sleep(3)
    next_page()